﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Editor.UI
{
    class Element<T>
    {
        public Element(T external)
        {
            ExternalElement = external;
        }

        public T ExternalElement
        {
            get;
            set;
        }
    }

    class ProgressBar :
        Game.UI.IProgressBar
    {
        public ProgressBar(System.Windows.Forms.ToolStripProgressBar eBar,
            System.Windows.Forms.ToolStripLabel eLabel)
        {
            Bar = new Element<System.Windows.Forms.ToolStripProgressBar>(eBar);
            Label = new Element<System.Windows.Forms.ToolStripLabel>(eLabel);
        }

        public Element<System.Windows.Forms.ToolStripProgressBar> Bar
        {
            get;
            set;
        }

        public Element<System.Windows.Forms.ToolStripLabel> Label
        {
            get;
            set;
        }

        public String Caption
        {
            get
            {
                return Label.ExternalElement.Text;
            }
            set
            {
                Label.ExternalElement.Text = value;
                Label.ExternalElement.Invalidate();
            }
        }

        public int Count
        {
            get
            {
                return Bar.ExternalElement.Maximum;
            }
            set
            {
                Bar.ExternalElement.Maximum = value;
            }
        }

        public int Value
        {
            get
            {
                return Bar.ExternalElement.Value;
            }
            set
            {
                Bar.ExternalElement.Visible = (value != Count);
                Label.ExternalElement.Visible = (value != Count);
                
                Bar.ExternalElement.Value = value;
                
                Bar.ExternalElement.Invalidate();
                Label.ExternalElement.Invalidate();
            }
        }
    }

    interface IStatusBar
    {
        uint Count
        {
            get;
            set;
        }

        uint Position
        {
            get;
            set;
        }
    }
}
